package com.lovestacks.tj.controller;

import com.lovestacks.tj.bean.ResultBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class ScoreInfoController {
    @RequestMapping("/getScore")
    @ResponseBody
    public ResultBean getScore(String openID){
        ResultBean bean = new ResultBean();
        try{
//            {
//                "desc": "success",
//                    "status": 200,
//                    "data": [
//                evaluateScore: 200,            // 评估分
//                        reviewScore: 30 | -1           // 审核分。返回-1表示待审核,
//                paimingList: [{                // 排名列表
//                menuName: '',              // 单位名称
//                        score: 28
//            },{
//                menuName: '',              // 单位名称
//                        score: 28
//            }]
//    ]
//            }
//          pass
            if ("test".equals(openID)){
                Map<String,Object> map = new HashMap<>();
                List<Map<String,Object>> list = new ArrayList<>();
                map.put("evaluateScore",200);
                map.put("reviewScore",-1);
                map.put("paimingList",list);
                bean.makeSuccess(map);
            }else {
                Map<String,Object> map = new HashMap<>();
                map.put("evaluateScore",200);
                map.put("reviewScore",30);

                List<Map<String,Object>> list = new ArrayList<>();
                Map<String,Object> map1 = new HashMap<>();
                Map<String,Object> map2 = new HashMap<>();
                Map<String,Object> map3 = new HashMap<>();
                map1.put("menuName","单位1");
                map1.put("score",27);
                map2.put("menuName","单位2");
                map2.put("score",28);
                map3.put("menuName","单位3");
                map3.put("score",29);
                list.add(map1);
                list.add(map2);
                list.add(map3);
                map.put("paimingList",list);
                bean.makeSuccess(map);
            }

        }catch (Exception e){
            e.fillInStackTrace();
            bean.makeFail(e.getMessage());
        }
        return bean;
    }
}
